package com.tuliyou.dto;

import com.tuliyou.entity.University;
import com.tuliyou.entity.User;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

/**
 * 院校信息DTO（用于前后端交互，映射universities表的核心字段）
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
public class UniversityDTO {

    private String universityCode; // 对应表中university_code

    private String name; // 对应表中name

    private Integer uniYear; // 对应表中uni_year

    private String province; // 对应表中province

    private String city; // 对应表中city

    private String attribute; // 对应表中attribute（ENUM类型，前端展示字符串）

    private String level; // 对应表中level

    private String description; // 对应表中description

    private String officialWebsite; // 对应表中official_website

    public static UniversityDTO fromUniversity(University university) {
        if (university == null) return null;

        return new UniversityDTO(
                university.getUniversityCode(),
                university.getName(),
                university.getUniYear(),
                university.getProvince(),
                university.getCity(),
                university.getAttribute(),
                university.getLevel(),
                university.getDescription(),
                university.getOfficialWebsite()
        );
    }
}